home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: Franz PD
/
Franz PD Disk #113 (1991-01)(Amiga User Group Deutschland e.V.).zip
/
Franz PD Disk #113 (1991-01)(Amiga User Group Deutschland e.V.).adf
/
Rätsel
/
Irre
(
.txt
)
< prev
next >
Wrap
AmigaBASIC Source Code
|
1989-07-03
|
7KB
|
309 lines
acbmname$="Baugrund"
REM IF FRE(1)<30000& THEN CLEAR,,30000&
DIM bPlane&(5), cTabWork%(32), cTabSave%(32)
DECLARE FUNCTION xOpen& LIBRARY
DECLARE FUNCTION xRead& LIBRARY
DECLARE FUNCTION xWrite& LIBRARY
DECLARE FUNCTION AllocMem&() LIBRARY
LIBRARY "dos.library"
LIBRARY "exec.library"
LIBRARY "graphics.library"
loadError$ = ""
GOSUB LoadACBM
IF loadError$ <> "" THEN GOTO Mcleanup
IF foundCCRT AND ccrtDir% THEN
FOR kk = 0 TO nColors% -1
cTabSave%(kk) = PEEKW(colorTab&+(kk*2))
cTabWork%(kk) = cTabSave%(kk)
NEXT
FOR kk = 0 TO 80
IF ccrtDir% = 1 THEN
GOSUB Fcycle
ELSE
GOSUB Bcycle
END IF
CALL LoadRGB4&(sViewPort&,VARPTR(cTabWork%(0)),nColors%)
FOR de1 = 0 TO ccrtSecs& * 3000
FOR de2 = 0 TO ccrtMics& / 500
NEXT
NEXT
NEXT
CALL LoadRGB4&(sViewPort&,VARPTR(cTabSave%(0)),nColors%)
END IF
Mcleanup:
GOTO spielanfang:
Mcleanup2:
REM LIBRARY CLOSE
IF loadError$ <> "" THEN PRINT loadError$
END
cTemp% = cTabWork%(ccrtEnd%)
FOR jj = ccrtEnd%-1 TO ccrtStart% STEP -1
cTabWork%(jj+1) = cTabWork%(jj)
NEXT
cTabWork%(ccrtStart%) = cTemp%
RETURN
Fcycle: '" Farbzyklus vorwärts (forward)
cTemp% = cTabWork%(ccrtStart%)
FOR jj = ccrtStart%+1 TO ccrtEnd%
cTabWork%(jj-1) = cTabWork%(jj)
NEXT
cTabWork%(ccrtEnd%) = cTemp%
RETURN
LoadACBM:
'" - Folgende Variablen müssen
'" - initialisiert sein:
REM - ACBMname$ (ACBM-Dateiname)
REM - Variablen initialisieren
f$ = acbmname$
fHandle& = 0
mybuf& = 0
foundBMHD = 0
foundCMAP = 0
foundCAMG = 0
foundCCRT = 0
foundABIT = 0
REM - aus include/libraries/dos.h
REM - MODE_NEWFILE = 1006
REM - MODE_OLDFILE = 1005
filename$ = f$ + CHR$(0)
fHandle& = xOpen&(SADD(filename$),1005)
IF fHandle& = 0 THEN
loadError$ = "Eingabedatei nicht gefunden/lesbar."
GOTO Lcleanup
END IF
REM - Pufferspeicherplatz reservieren
ClearPublic& = 65537
mybufsize& = 360
mybuf& = AllocMem&(mybufsize&,ClearPublic&)
IF mybuf& = 0 THEN
loadError$ = "Pufferspeicherplatz nicht verfügbar."
GOTO Lcleanup
END IF
inbuf& = mybuf&
cbuf& = mybuf& + 120
ctab& = mybuf& + 240
REM - Eingabe sollte lauten FORMnnnnACBM
rLen& = xRead&(fHandle&,inbuf&,12)
tt$ = ""
FOR kk = 8 TO 11
tt% = PEEK(inbuf& + kk)
tt$ = tt$ + CHR$(tt%)
NEXT
IF tt$ <> "ACBM" THEN
loadError$ = "Keine ACBM-Grafikdatei."
GOTO Lcleanup
END IF
REM - ACBM-Datei Chunk-weise lesen
ChunkLoop:
REM - Chunk-Name/Länge ermitteln
rLen& = xRead&(fHandle&,inbuf&,8)
icLen& = PEEKL(inbuf& + 4)
tt$ = ""
FOR kk = 0 TO 3
tt% = PEEK(inbuf& + kk)
tt$ = tt$ + CHR$(tt%)
NEXT
IF tt$ = "BMHD" THEN 'BitMap-Header
foundBMHD = 1
rLen& = xRead&(fHandle&,inbuf&,icLen&)
iWidth% = PEEKW(inbuf&)
iHeight% = PEEKW(inbuf& + 2)
iDepth% = PEEK(inbuf& + 8)
iCompr% = PEEK(inbuf& + 10)
scrWidth% = PEEKW(inbuf& + 16)
scrHeight% = PEEKW(inbuf& + 18)
iRowBytes% = iWidth% /8
scrRowBytes% = scrWidth% / 8
nColors% = 2^(iDepth%)
'" - Genug Platz für Videospeicher ?
AvailRam& = FRE(-1)
NeededRam& = ((scrWidth%/8)*scrHeight%*(iDepth%+1))+5000
IF AvailRam& < NeededRam& THEN
loadError$ = "Speicherplatz reicht nicht aus."
GOTO Lcleanup
END IF
kk = 1
IF scrWidth% > 320 THEN kk = kk + 1
IF scrHeight% > 200 THEN kk = kk + 2
SCREEN 2,scrWidth%,scrHeight%,5,1
WINDOW 2,"",,0,2
CALL freesprite (0)
REM - Adressen von Screen-Structures ermitteln
GOSUB GetScrAddrs
REM - Schirm während Ladevorgang dunkel
CALL LoadRGB4&(sViewPort&,ctab&,nColors%)
ELSEIF tt$ = "CMAP" THEN 'Farbpalette
foundCMAP = 1
rLen& = xRead&(fHandle&,cbuf&,icLen&)
REM - Farbpalette aufbauen
FOR kk = 0 TO nColors% - 1
red% = PEEK(cbuf&+(kk*3))
gre% = PEEK(cbuf&+(kk*3)+1)
blu% = PEEK(cbuf&+(kk*3)+2)
regTemp% = (red%*16)+(gre%)+(blu%/16)
POKEW(ctab&+(2*kk)),regTemp%
NEXT
ELSEIF tt$ = "CAMG" THEN 'Amiga ViewPort Modes
foundCAMG = 1
rLen& = xRead&(fHandle&,inbuf&,icLen&)
camgModes& = PEEKL(inbuf&)
ELSEIF tt$ = "CCRT" THEN 'Graphicraft-Farbzyklus-Daten
foundCCRT = 1
rLen& = xRead&(fHandle&,inbuf&,icLen&)
ccrtDir% = PEEKW(inbuf&)
ccrtStart% = PEEK(inbuf& + 2)
ccrtEnd% = PEEK(inbuf& + 3)
ccrtSecs& = PEEKL(inbuf& + 4)
ccrtMics& = PEEKL(inbuf& + 8)
ELSEIF tt$ = "ABIT" THEN 'Contiguous BitMap
foundABIT = 1
'" - Hier werden nur volle BitMaps verarbeitet, keine
'" - Ausschnitte wie z.B. Pinsel (Brushes).
'" - Sehr schnell, liest ganze BitPlanes.
plSize& = (scrWidth%/8) * scrHeight%
FOR pp = 0 TO iDepth% -1
rLen& = xRead&(fHandle&,bPlane&(pp),plSize&)
NEXT
ELSE
REM - unbekannten Chunk-Typ lesen
FOR kk = 1 TO icLen&
rLen& = xRead&(fHandle&,inbuf&,1)
NEXT
'" - Wenn Länge ungerade, noch 1 Byte lesen
IF (icLen& OR 1) = icLen& THEN
rLen& = xRead&(fHandle&,inbuf&,1)
END IF
END IF
REM - Fertig, wenn alle Chunks gelesen
IF foundBMHD AND foundCMAP AND foundABIT THEN
GOTO GoodLoad
END IF
REM - Lesen ok, nächsten Chunk lesen
IF rLen& > 0 THEN GOTO ChunkLoop
IF rLen& < 0 THEN ' Lesefehler
loadError$ = "Lesefehler."
GOTO Lcleanup
END IF
REM - rLen& = 0 heißt EOF (Dateiende)
IF (foundBMHD=0) OR (foundABIT=0) OR (foundCMAP=0) THEN
loadError$ = "Wichtige IFF-Chunks nicht gefunden."
GOTO Lcleanup
END IF
GoodLoad:
loadError$ =""
REM Farbpalette
IF foundCMAP THEN
CALL LoadRGB4&(sViewPort&,ctab&,nColors%)
END IF
Lcleanup:
IF fHandle& <> 0 THEN CALL xClose&(fHandle&)
IF mybuf& <> 0 THEN CALL FreeMem&(mybuf&,mybufsize&)
RETURN
GetScrAddrs:
REM - Adressen von Screen-Structures ermitteln
sWindow& = WINDOW(7)
sScreen& = PEEKL(sWindow& + 46)
sViewPort& = sScreen& + 44
sRastPort& = sScreen& + 84
sColorMap& = PEEKL(sViewPort& + 4)
colorTab& = PEEKL(sColorMap& + 4)
sBitMap& = PEEKL(sRastPort& + 4)
REM - Screen-Parameter ermitteln
scrWidth% = PEEKW(sScreen& + 12)
scrHeight% = PEEKW(sScreen& + 14)
scrDepth% = PEEK(sBitMap& + 5)
nColors% = 2^scrDepth%
REM - Adressen der BitPlanes ermitteln
FOR kk = 0 TO scrDepth% - 1
bPlane&(kk) = PEEKL(sBitMap&+8+(kk*4))
NEXT
RETURN
spielanfang:
LINE (270,235)-(305,255),7,bf
LOCATE 31,35:COLOR 5,7:PRINT "ENDE"
anfang:
ON MOUSE GOSUB mausdruck
MOUSE ON
WHILE 1 : WEND
mausdruck:
druck=MOUSE(0)
x=MOUSE(3) : y=MOUSE(4)
IF x>280 AND x<305 AND y>236 AND y<254 THEN GOTO ende
IF x>120 AND x<210 AND y>235 AND y<255 THEN GOTO aufloesung
GOTO anfang
aufloesung:
LINE (0,141)-(330,230),12,bf
LOCATE 20,3:COLOR 4,12: PRINT "AUFLÖSUNG:"
LOCATE 22,3:PRINT "255m + 300m = 555m
LOCATE 24,3:PRINT "Ein Strich läßt sich schwer verkaufen."
GOTO anfang
END
ende:
WINDOW CLOSE 1
SCREEN CLOSE 1
SYSTEM
END
'**********************************************************************
' Detlef Kornatz
' Feuerbachstraße 6
' D-4300 ESSEN 1
'***********************************************************************